<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/
  defined('_JEXEC') or die('Retricted Access');

  if(!$this->item->id){
  	echo JText::_('Not found empoyer');
  	return;
  }
  else{
    JFilterOutput::objectHTMLSafe( $this->item );
    
    $user = &JFactory::getUser();
    $user->username = str_replace('.','()',$user->username);
    $acc_item = $this->item;
    if ($user->get('lastvisitDate') == "0000-00-00 00:00:00") {
		$lvisit = JText::_( 'Never' );
	} else {
		$lvisit	= generateDate($user->get('lastvisitDate'));
	}
	$user_type = JRequest::getVar('user_type');
	
	// Google map data
	global $jbconfig;	
	$mapLocation = $jbconfig['general']->get('map_ja_profiles', "address");
?>
<script type="text/javascript" language="javascript">
    function submitbutton(pressbutton){
        
        form.task.value = pressbutton;
        form.submit();
    }
</script>
<div id="jobboard-content">
<?php if ($user->id==$this->item->user_id) { ?>
<div class="moduletable job-box">	

	<form name="userdetailForm" action="<?php echo JURI::root();?>index.php" method="post">
		<?php if (getCurrentUserType($user->id)=='Guest') { ?>
		<table class="tabledata userdetails">
			<tr>
				<td>
				
					<?php echo JText::_('You don\'t have update your information detail!'); ?>
					<a class="button" href="<?php echo JRoute::_( 'index.php?option=com_jajobboard&view=usergroup'); ?>"><?php echo JText::_('Update now'); ?></a>
				
				</td>
			</tr>
		</table>
		<?php } ?>
      	<h3>
	          <?php echo JText::_( 'Information details' ); ?>
	    </h3>
	    <table class="tabledata userdetails">												
			<tr>
				<td class="key">
					<?php echo JText::_('Name'); ?>
				</td>
				<td>
					<?php echo $user->get('name'); ?>
				</td>
			</tr>
			<tr>
				<td class="key">
					<?php echo JText::_('Username'); ?>
				</td>
				<td>
					<?php echo $user->get('username'); ?>
				</td>
			</tr>
			<tr>
				<td class="key">
					<?php echo JText::_('Email'); ?>
				</td>
				<td>
					<?php echo $user->get('email'); ?>
				</td>
			</tr>
			
			<?php  if( $user->get('id') ) { ?>
			<tr>
				<td class="key">
					<?php echo JText::_('Register Date'); ?>:
				</td>
				<td>
					<?php echo generateDate($user->get('registerDate'));?>
				</td>
			</tr>
			<tr>
				<td class="key">
					<?php echo JText::_('Last Visit Date'); ?>:
				</td>
				<td>
					<?php echo $lvisit; ?>
				</td>
			</tr>
			<?php } ?>
			
		</table>
		<table class="tabledata userdetails">
			<tr>
				<td align="right" style="text-align: right !important">
					<?php if (JRequest::getVar('view')!='jausergroup'){?>
						<img title="<?php echo JText::_('Edit resume'); ?>" src="<?php echo JURI::base().'components/com_jajobboard/images/icon_edit.png' ?>" alt="<?php echo JText::_('Edit resume'); ?>" />
	                    &nbsp;
	                    <a href="<?php echo JRoute::_( 'index.php?option=com_user&view=user&layout=form&Itemid='.JRequest::getVar('Itemid')); ?>" title="<?php echo JText::_('Click here to edit your detail')?>">
	                    	<span style="vertical-align: top !important;"><?php echo JText::_('Edit My Detail'); ?></span>
	                    </a>				
					<?php }?>
				</td>
			</tr>
		</table>		
		
		<input type="hidden" name="cid" value="<?php echo $user->id; ?>" />
		<input type="hidden" name="option" value="<?php echo $option; ?>" />
		<input type="hidden" name="view" value="usergroup" />
		<input type="hidden" name="task" value="" />
		<?php echo JHTML::_( 'form.token' ); ?>	
		
	</form>
</div>

<?php } ?>
<div style="clear:both"></div>
<form name="adminForm" action="index.php" method="post">
<?php
	if($this->item->id){
	?>
  <div class="moduletable profile-box">
    <table class="tabledata profiledetails">
    <?php
    $k=0;
    for($i = 0, $n = count($this->fieldlist); $i < $n; $i++ ){
        $field = $this->fieldlist[$i];
        
        if($field->display=='admin_only' && $user->aid<2) continue;
		            
		if($field->display=='hide_all' || $field->display=='hide_on_view') continue;
        
        $field_name = $field->field_name;
        $firstIndex = findFirstField($this->item,$this->fieldlist);
		$lastIndex = findLastField($this->item,$this->fieldlist);  
		$input = rendfield($this->item, $field, false, true, true);
		                      
        if($field->field_type=='SEPERATOR' ){?>
    </table>
	</div>

  	<div class="moduletable profile-box"> 
  		<?php if($input!=''){?>
		<h3><?php echo $input;?></h3>
		<?php }?>
		<table class="tabledata profiledetails">
	    <?php }else{
	             	if ($i==$firstIndex)
			      		$classname = 'first';
			      	elseif ($i==$lastIndex)
			      		$classname = 'last';
			      	else 
			      		$classname = 'sectiontableentry'.($k+1);
	             ?>
	               		<tr class="<?php echo $classname; ?>">
	                        <td width="20%">
	                        <?php echo JText::_($field->label); ?>:
	                        </td>
	                        <td width="80%">
	                           <?php echo $input;?>
	                           <?php 
					           	// Check to show Google Map
					           	if( $field->field_name == $mapLocation && $input != "") {?>
					           	{jamap to_location='<?php echo $input;?>'}
					           	<?php }?>
	                        </td>
	                    </tr>      
		                
	                <?php $k = 1 - $k;?>			                   
	          	<?php }
	          
	      }?>
		</table>  
  </div>

	
  <div class="moduletable profile-box"> 
    <table class="tabledata profiledetails">
        <tr>
            <?php if(JRequest::getVar('step') == 'verify') {?>
            <td align="right">                        	
                <a class="button" href="<?php echo 'index.php?option=com_jajobboard&view=japrofiles&task=save&step=done&cid[]='.$this->item->user_id; ?>"><?php echo JText::_('Done'); ?></a>&nbsp;
                <a class="button" href="<?php echo JRoute::_( 'index.php?option=com_jajobboard&view=japrofiles&layout=jaform&cid[]='.$this->item->user_id ); ?>"><?php echo JText::_('Modify'); ?></a>
            </td>
            <?php } else {?>
            <td align="right" style="text-align: right !important;">
                <?php 
                if(getCurrentUserType() == JBEMPLOYER_USER && $this->item->user_id == $user->id){
                    $alias = JFilterOutput::stringURLSafe($user->name);    
                    ?>
                     	<img title="<?php echo JText::_('Edit Profile'); ?>" src="<?php echo JURI::base().'components/com_jajobboard/images/icon_edit.png' ?>" alt="<?php echo JText::_('Edit Profile'); ?>" />
						&nbsp;
						<a href="<?php echo JRoute::_('index.php?option=com_jajobboard&view=japrofiles&layout=jaform&cid[]='.$this->item->user_id.'&alias='.$alias.'&Itemid='.JRequest::getVar('Itemid') ); ?>" >
							<span style="vertical-align: top !important;"><?php echo JText::_('Edit Profile'); ?></span>
						</a> 
						&nbsp;
			              
			            <img title="<?php echo JText::_('Back'); ?>" src="<?php echo JURI::base().'components/com_jajobboard/images/Undo-16x16.png' ?>" alt="<?php echo JText::_('Back'); ?>" />
						&nbsp;
						<a href="javascript:window.history.go(-1);" title="Back">
							<span style="vertical-align: top !important;"><?php echo JText::_('Back'); ?></span>
						</a> 
						  	
                <?php } else if($this->fromsearch == 1) {?>
                <a class="button" href="javascript:window.history.go(-1);"><?php echo JText::_('Back'); ?></a>
                <?php } else { ?>           
                	    
                 	<img title="<?php echo JText::_("Click here to view Company's jobs"); ?>" src="<?php echo JURI::base().'components/com_jajobboard/images/Preview-16x16.png' ?>" alt="<?php echo JText::_("Company's jobs"); ?>" />
					&nbsp;
					<?php 
						$user_temp = JFactory::getUser($this->item->user_id); 
						$user_temp->username = str_replace('.','()',$user_temp->username);
						$Itemid = get_Itemid(array('option'=>'com_jajobboard', 'view'=>'jajobs', 'layout'=>'jalist'));
					?>
					<a href="<?php echo JRoute::_('index.php?option=com_jajobboard&view=jajobs&layout=myjobs&employerid='.$this->item->user_id.'&uid='.$user_temp->username.'&Itemid='.$Itemid)?>" title="<?php echo JText::_("Click here to view Company's jobs"); ?>">
						<span style="vertical-align: top !important;"><?php echo JText::_("Company's jobs"); ?></span>
					</a> 
					&nbsp;
						
                 	<img title="<?php echo JText::_('Back'); ?>" src="<?php echo JURI::base().'components/com_jajobboard/images/Undo-16x16.png' ?>" alt="<?php echo JText::_('Back'); ?>" />
					&nbsp;
					<a href="javascript:window.history.go(-1);" title="Back">
						<span style="vertical-align: top !important;"><?php echo JText::_('Back'); ?></span>
					</a>
                <?php } ?>
            </td>
            <?php } ?>
            
        </tr>
    </table>
  </div>
  <?php }else{?>
  	<font style="color: red; font-weight: bold;"><?php echo JText::_('Profile not found.')?></font> 
  <?php }?>      
	<input type="hidden" name="cid[]" value="<?php echo $this->item->id; ?>" />
	<input type="hidden" name="option" value="<?php echo JBCOMNAME; ?>" />
	<input type="hidden" name="view" value="japrofiles" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="Itemid" value="<?php echo JRequest::getInt('Itemid', 0); ?>" />
	<?php echo JHTML::_( 'form.token' ); ?>	
 </form>

</div>
<?php }?>